<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/9/5
 * Time: 00:09
 */
namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Repositories\AppVersionUpgradesRepository;
use Illuminate\Http\Request;

class ChannelQrcodeController extends Controller
{
    protected $appVersionUpgradesRepository;

    public function __construct(AppVersionUpgradesRepository $appVersionUpgradesRepository)
    {
        $this->appVersionUpgradesRepository = $appVersionUpgradesRepository;
    }

    /**
     * 下载app
     */
    public function downloadApp()
    {
        $isWhatClient = whatClientFromMobile();
        switch ($isWhatClient) {
            //IOS
            case 1:
                $data = $this->appVersionUpgradesRepository->findToAppType(2);
                break;
            //Android
            case 2:
                $data = $this->appVersionUpgradesRepository->findToAppType(1);
                break;
            case 3:
                $data = $this->appVersionUpgradesRepository->findToAppType(1);
                break;
        }
        if (!empty($data)) {
            $downUrl = $data->download_url;
        } else {
            $downUrl = '';
        }
        return view('web.channelQrcode.downloadApp', compact('downUrl'));
    }
}